//
//  M StatusCell.swift
//  iOSweibo
//
//  Created by lzm on 16/5/18.
//  Copyright © 2016年 lzm. All rights reserved.
//

import UIKit
import SnapKit

private let MStatusCellMargin:CGFloat = 8

class M_StatusCell: UITableViewCell {
    
    //cell显示内容需要模型
    var status : MStatus? {
        didSet{
            OriginalView.status = status
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        prepareUI()
        
    }

    private func prepareUI()
    {
        backgroundColor = UIColor(white: 237/255.0, alpha: 1.0)

        //添加到contentView 上
        contentView.addSubview(OriginalView)
        contentView.addSubview(bottomView)
        
        
        //添加约束
        OriginalView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(contentView).offset(10)
            make.leading.equalTo(contentView)
            make.trailing.equalTo(contentView)
//            make.height.equalTo(Int(arc4random_uniform(100))+50)
        }
        
        bottomView.snp_makeConstraints { (make) -> Void in
            make.leading.equalTo(contentView)
            make.top.equalTo(OriginalView.snp_bottom)
            make.trailing.equalTo(contentView)
            make.height.equalTo(37)
        }
        
        contentView.snp_makeConstraints { (make) -> Void in
            make.leading.equalTo(self)
            make.top.equalTo(self)
            make.trailing.equalTo(self)
            
            // contentView的高度不要去参照cell,cell的高度本来就是来参照contentView的高度
            // contentView的底部约束需要参照子控件
            make.bottom.equalTo(bottomView)
        }
        
        
    }
    
    //MARK: 懒加载
    private lazy var OriginalView : M_StatusOriginalView = M_StatusOriginalView()
    //底部bottom
    private lazy var bottomView : MStausBottom = MStausBottom()

}
